﻿namespace MicroCloud.Audit.Entities
{
    /// <summary>
    /// 实体类：审计操作信息
    /// </summary>
    [MapFrom(typeof(AuditOperationEntry))]
    [Table(nameof(AuditOperation), Schema = TableSchemaConstants.Audit)]
    [Description("审计操作信息")]
    [EventEntityIgnore]
    [ValueGenerate(ValueGenerateRule.Never, ValueGenerateMode.Snowflake)]
    public class AuditOperation : EntityBase<long>
    {
        #region "属性"
        #region "获取或设置 执行的功能名"
        private string _FunctionName = "";
        /// <summary>
        /// 获取或设置 执行的功能名
        /// </summary>
        [Column("FunctionName")]
        [Required, DefaultValue("")]
        [StringSize(StringSizeType.Name)]
        [DisplayName("执行的功能名")]
        public string FunctionName { get { return _FunctionName; } set { _FunctionName = value.ReplaceNull(); } }
        #endregion
        #region "获取或设置 用户编号"
        private string _UserId = "";
        /// <summary>
        /// 获取或设置 用户编号
        /// </summary>
        [Column("UserId")]
        [StringSize(StringSizeType.Code)]
        [DisplayName("用户编号")]
        public string UserId { get { return _UserId; } set { _UserId = value.ReplaceNull(); } }
        #endregion
        #region "获取或设置 访问IP"
        private string _Ip = "";
        /// <summary>
        /// 获取或设置 访问IP
        /// </summary>
        [Column("Ip")]
        [StringSize(StringSizeType.Code)]
        [DisplayName("访问IP")]
        public string Ip { get { return _Ip; } set { _Ip = value.ReplaceNull(); } }
        #endregion
        #region "获取或设置 操作系统"
        private string _OperationSystem = "";
        /// <summary>
        /// 获取或设置 操作系统
        /// </summary>
        [Column("OperationSystem")]
        [StringSize(StringSizeType.Code)]
        [DisplayName("操作系统")]
        public string OperationSystem
        {
            get { return _OperationSystem; }
            set { _OperationSystem = value.ReplaceNull(); }
        }
        #endregion
        #region "获取或设置 浏览器"
        private string _Browser = "";
        /// <summary>
        /// 获取或设置 浏览器
        /// </summary>
        [Column("Browser")]
        [StringSize(StringSizeType.Code)]
        [DisplayName("浏览器")]
        public string Browser { get { return _Browser; } set { _Browser = value.ReplaceNull(); } }
        #endregion
        #region "获取或设置 当前访问用户代理（UserAgent）"
        private string _UserAgent = "";
        /// <summary>
        /// 获取或设置 当前访问用户代理（UserAgent）
        /// </summary>
        [Column("UserAgent")]
        [StringSize(StringSizeType.General)]
        [DisplayName("当前访问用户代理")]
        public string UserAgent { get { return _UserAgent; } set { _UserAgent = value.ReplaceNull(); } }
        #endregion
        #region "获取或设置 HTTP请求方法"
        private string _Method = "";
        /// <summary>
        /// 获取或设置 HTTP请求方法
        /// </summary>
        [Column("Method")]
        [StringSize(StringSizeType.Key)]
        [DisplayName("请求方法")]
        public string Method { get { return _Method; } set { _Method = value.ReplaceNull(); } }
        #endregion
        #region "获取或设置 HTTP请求内容类型"
        private string _ContentType = "";
        /// <summary>
        /// 获取或设置 HTTP请求内容类型
        /// </summary>
        [Column("ContentType")]
        [StringSize(StringSizeType.Code)]
        [DisplayName("请求内容类型")]
        public string ContentType { get { return _ContentType; } set { _ContentType = value.ReplaceNull(); } }
        #endregion
        #region "获取或设置 HTTP请求查询字符串"
        private string _QueryString = "";
        /// <summary>
        /// 获取或设置 HTTP请求查询字符串
        /// </summary>
        [Column("QueryString")]
        [StringSize(StringSizeType.Remark)]
        [DisplayName("请求查询字符串")]
        public string QueryString { get { return _QueryString; } set { _QueryString = value.ReplaceNull(); } }
        #endregion
        #region "获取或设置 HTTP请求参数"
        private string _Arguments = "";
        /// <summary>
        /// 获取或设置 HTTP请求参数
        /// </summary>
        [Column("Arguments")]
        [StringMax]
        [DisplayName("请求参数")]
        public string Arguments { get { return _Arguments; } set { _Arguments = value.ReplaceNull(); } }
        #endregion
        #region "获取或设置 操作结果"
        /// <summary>
        /// 获取或设置 操作结果
        /// </summary>
        [Column("ResultType")]
        [DisplayName("操作结果")]
        public AjaxResultType ResultType { get; set; } = AjaxResultType.Success;
        #endregion
        #region "获取或设置 消息"
        private string _Message = "";
        /// <summary>
        /// 获取或设置 消息
        /// </summary>
        [Column("Message")]
        [StringSize(StringSizeType.Content)]
        [DisplayName("消息")]
        public string Message { get { return _Message; } set { _Message = value.ReplaceNull(); } }
        #endregion
        #region "获取或设置 结果数据"
        private string _ResultData = "";
        /// <summary>
        /// 获取或设置 结果数据
        /// </summary>
        [Column("ResultData")]
        [StringMax]
        [DisplayName("结果数据")]
        public string ResultData { get { return _ResultData; } set { _ResultData = value.ReplaceNull(); } }
        #endregion
        #region "获取或设置 执行耗时(毫秒)"
        /// <summary>
        /// 获取或设置 执行耗时(毫秒)
        /// </summary>
        [Column("Elapsed")]
        [DisplayName("执行耗时（毫秒）")]
        public int Elapsed { get; set; }
        #endregion
        #region "获取或设置 信息添加时间"
        /// <summary>
        /// 获取或设置 信息添加时间
        /// </summary>
        [Column("CreatedTime")]
        [DisplayName("信息添加时间")]
        public DateTime CreatedTime { get; set; }
        #endregion

        // 导航属性
        #region "获取或设置 审计实体信息集合"
        /// <summary>
        /// 获取或设置 审计实体信息集合
        /// </summary>
        public virtual ICollection<AuditEntity> AuditEntities { get; set; } = new List<AuditEntity>();
        #endregion

        #endregion

    }
}